<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div class="ye">
        <div class="fa">
            <div class="son"></div>
            <div class="son1"></div>
            <div class="son2"></div>
        </div>
    </div>

    <ul>
        <li>1</li>
        <li>2</li>
        <li>3</li>
        <div>这是一个div</div>
        <li>4</li>
        <li>5</li>
    </ul>


    <script>
        //查找父节点   子元素.parentNode   返回最近的一级父节点 找不到则会返回Null
        const son = document.querySelector('.son')
        console.log(son.parentNode)   
        // console.log(son.parentNode.parentNode)


        //查找子节点   //ul.parentNode  获得的结果为伪数组型的
        const ul = document.querySelector('ul')
        console.log(ul.children)
        console.log(ul.children[3]);



        //查找兄弟节点
        // 查找下一个子节点
        console.log(ul.children[3].nextElementSibling)
        //查找上一个子节点
        console.log(ul.children[3].previousElementSibling)
        
    </script>
</body>
</html>